package com.example.demo.service;

import com.example.demo.entity.ArticleInfo;
import com.example.demo.entity.vo.ArticleInfoVo;
import com.example.demo.mapper.ArticleMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {
    @Autowired
    private ArticleMapper articleMapper;


    public int add(ArticleInfo articleInfo){
        return articleMapper.add(articleInfo);
    }

    public ArticleInfo getDetailByIdAndUid(Integer id,Integer uid){
        return articleMapper.getDetailByIdAndUid(id, uid);
    }
    public int update(ArticleInfo articleInfo){
        return articleMapper.update(articleInfo);
    }

    public ArticleInfoVo getDetail(Integer id){
        return articleMapper.getDetail(id);
    }

    public int addRCount(Integer id){
        return articleMapper.addRCount(id);
    }

    public List<ArticleInfo> countArticle(Integer uid){
        return articleMapper.countArticle(uid);
    }

    public ArticleInfo selectArticleById(Integer id){
        return articleMapper.selectArticleById(id);
    }

    public List<ArticleInfo> getAllArticle(Integer id){
        return articleMapper.getAllArticle(id);
    }
    public int del(Integer id,Integer uid){
        return articleMapper.del(id,uid);
    }

    public List<ArticleInfo> getAllArticleByPage(Integer pageSize, Integer offset,Integer state){
        return articleMapper.getAllArticleByPage(pageSize,offset,state);
    }

    public List<ArticleInfo> getAllArticleByPageFromUser(Integer pageSize, Integer offset, Integer uid, Integer state){
        return articleMapper.getAllArticleByPageFromUser(pageSize,offset,uid,state);
    }

    public Integer getArticle(Integer state){
        return articleMapper.getArticle(state);
    }


    public int getArticleFromUser(Integer uid ,Integer state) {
        return articleMapper.getArticleFromUser(uid, state);
    }


    public ArticleInfoVo getImagePath(Integer id) {
        return articleMapper.getImagePath(id);
    }

    public Integer getCount(){
        return articleMapper.getCount();
    }


    public int saveArticle(ArticleInfo articleInfo){
        return articleMapper.saveArticle(articleInfo);
    }


    public List<ArticleInfo> getAllArticleByPageNotSub(Integer pageSize, Integer offset, Integer uid, Integer state) {
        return articleMapper.getAllArticleByPageNotSub(pageSize,offset,uid,state);
    }

    public int getArticleNotSub(Integer uid,Integer state){
        return articleMapper.getArticleNotSub(uid,state);
    }

    public int autoSaveArticle(ArticleInfo articleInfo) {
        return articleMapper.autoSaveArticle(articleInfo);
    }



}
